package com.neutech.variable;

/**
 * String类的讲解
 * @author Neuedu-远哥
 * @version 1.0
 * @date 2021/11/9 10:13
 */
public class Demo06 {
    public static void main(String[] args) {
        String str1 = "1asdjfleasdjfk3lasbeasdfjkle";
        String str2 = "10";
        String str3 = new String("abc");
        int num1 = 10;
        int num2 = 20;
        // + 左右两边如果有String类型时，字符串连接符
        String result = num1 + num2 + str1;
        // 结果为10201
        System.out.println("结果为：" + result);
        System.out.println(str1.length());
        System.out.println(str1.charAt(17));
        System.out.println(str1.indexOf("asd"));
        String str4 = "";
        System.out.println(str4.isEmpty() + "length为：" + str4.length());
        String path = "http://www.baidu.com/register.do";
        // /login
        int beginIndex = path.lastIndexOf("/");
        int endIndex = path.lastIndexOf(".");
        String subResult = path.substring(beginIndex,endIndex);
        System.out.println(subResult);
        // 400-800-1234 -> 4008001234
        String originString = "400-800-1234";
        System.out.println(originString.replace("-",""));
        String str5 = "   aaaaa    bbbb    cccc     ";
        System.out.println("去空格前：" + str5);
        System.out.println("去空格后：" + str5.trim());
    }
}
